home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / new_file / utilitys / deskcloc / deskcloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-25  |  1.9 KB  |  70 lines

  1. #include <string.h>            /*Standard includes*/
  2. #include <stddef.h>
  3. #include <aes.h>
  4. #include <NEW_AES.h>
  5. #include <time.h>
  6. #include <stdlib.h>
  7.  
  8.  
  9. int main(int, char *[] );    /*variables definitions*/
  10. short app_id, menu_id;
  11. char time_title[9] = "  Time: ";
  12. char display[20] = "  Time:";
  13. char real_time[13];
  14. char *infostring = "[0][Desk clock accessory by |Yanick Dufresne|Email: y.dufresne|Version 1.0|(C) 1994, Freeware!][OK]";
  15. char *errstring = "[3][menu_register() returned -1][exit]";
  16. int msg[8], minute=-1;
  17. EVENT my_event= {MU_MESAG|MU_TIMER,        /* Event definition: message and timer */
  18.                         0,0,0,
  19.                         0,0,0,0,0,
  20.                         0,0,0,0,0,
  21.                         2000,0,            /* 2000 ms or 2 sec delay */
  22.                         0,0,0,0,0,0,0,0};
  23.  
  24. typedef long time_t;
  25. time_t cal;
  26. struct tm *ptable;
  27. char *fmt = "%a, %H:%M";
  28.  
  29.  
  30. int
  31. main ()                /* Main program */
  32. {
  33.  
  34.     if( (app_id = appl_init() )== -1)        /* Initialize AES */
  35.         return -1;                            /* return -1 if error */
  36.         
  37.     if((menu_id = menu_register(app_id, display)) == -1) /* register in menu*/
  38.         {
  39.         form_alert( 1, errstring);        /* Alert and return if error*/
  40.         return -1;
  41.         }
  42.  
  43.     for(;;)        /* Infinite loop  */
  44.     {
  45.  
  46.         cal = time (0);                    /* Set calander time in cal */
  47.         ptable = localtime ( &cal );    /* Translate to local time */
  48.  
  49.         if(!( minute == ptable->tm_min))  /* update if one minute has passed */
  50.         {
  51.             minute = ptable->tm_min;
  52.             strftime( &real_time[0], 12, fmt, ptable ); /* format it */
  53.             strcpy( display,time_title );    /* set display to time_title */
  54.             strcat( display, real_time );    /* + real_time */
  55.     
  56.             if(_app) menu_register(app_id, display); /* if run as PRG, update tear-offs */
  57.         }
  58.         
  59.         
  60.         
  61.         EvntMulti (&my_event);            /* ZZZZZZ */
  62.  
  63.         if(my_event.ev_mwich & MU_MESAG        /* is it a message? */
  64.             && my_event.ev_mmgpbuf[0] == AC_OPEN)     /* to open? */
  65.                 form_alert(2, infostring);            /* hello, it's me! */
  66.     
  67.             /* else, the event was timer and it's time to update */
  68.  
  69.     }
  70. }